/**
 * 搜搜页
 */
export default {
   namespaced: true,
   state() {
      return {
         search_kwd: sessionStorage.getItem('search_kwd') || '', // 搜索的关键字
         search_res: JSON.parse(sessionStorage.getItem('search_res') || '[]') // 搜索结果
      }
   },
   actions: {},
   mutations: {
      /* 存储搜索到的结果存到数组中 */
      SAVE_SEARCH_RES(state, {shops, kwd}) {
         sessionStorage.setItem('search_kwd', kwd)
         state.search_kwd = kwd
         sessionStorage.setItem('search_res', JSON.stringify(shops))
         state.search_res = shops
      },
      /* 清空搜索结果 */
      CLEAR_SEARCH_RES(state) {
         state.search_kwd = ''
         state.search_res = []
         sessionStorage.removeItem('search_kwd')
         sessionStorage.removeItem('search_res')
      }
   },
   getters: {}
}